1. Field of the Invention
The present invention generally relates to a technique for accessing data and managing memory blocks, in particular, to a technique for accessing data and managing memory blocks which can extend the lifespan of a storage apparatus.
2. Description of Related Art
FIG. 1 is a diagram of a non-volatile memory structure. Referring to FIG. 1, the non-volatile memory 100 (for example, a flash memory) includes a plurality of memory blocks, such as memory blocks 102, 104, and 106, for storing data. These memory blocks are arranged as an array therefore can be referred as a memory block array. Each of the memory blocks has a storage space of a particular capacity. However, errors may occur to some bits in these memory blocks after these memory blocks are used for some time, and these erroneous bits may be referred as error bits. Conventionally, when error bits are found in a memory block, these error bits are corrected through bit correction and the corrected bits are detected as error correction bits or error correction code (ECC).
FIG. 2 is a diagram illustrating a conventional method for managing a memory block. Referring to FIG. 2, the conventional non-volatile memory (for example, a flash memory) can be divided into a normal block table 202 and a disabled block table 204. Conventionally, a memory block is placed into the normal block table 202 when the number of error correction bits in the memory block is determined to be lower than a predetermined value. Accordingly, data in the memory blocks in the normal block table 202 of the flash memory can be accessed normally.
On the other hand, if the number of error correction bits in a memory block is determined to be higher than the predetermined value (N-Bit ECC), for example, higher than 4, data error may occur when data is stored in the memory block. Thus, conventionally, this memory block is placed into the disabled block table 204 so that data will not be stored into a memory block in the disabled block table 204. If the disabled block table 204 has no more available space, the flash memory will be locked so that data cannot be written into the flash memory anymore.
Even though the memory blocks in the normal block table are all usable memory blocks, many usable memory blocks are actually at the edge of being disabled. For example, assuming the above predetermined value is 4, the numbers of error correction bits in some memory blocks may be 3 or exactly 4. Namely, these memory blocks have to be moved from the normal block table 202 to the disabled block table 204 once another 1 or 2 error correction bits occur in these memory blocks. However, conventionally, how many error correction bits a memory block of a non-volatile memory has is not taken into consideration when data is stored into the memory block. Thus, if those memory blocks at the edge of being disabled are always used for data accessing, these memory blocks will soon be disabled and accordingly the lifespan of the non-volatile memory will be shortened.